home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JSlider;
- import com.sun.java.swing.KeyStroke;
- import com.sun.java.swing.LookAndFeel;
- import com.sun.java.swing.Timer;
- import com.sun.java.swing.UIManager;
- import com.sun.java.swing.plaf.ComponentUI;
- import com.sun.java.swing.plaf.SliderUI;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.IllegalComponentStateException;
- import java.awt.Insets;
- import java.awt.Polygon;
- import java.awt.Rectangle;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import java.io.Serializable;
- import java.util.Dictionary;
- import java.util.Enumeration;
-
- public class BasicSliderUI extends SliderUI implements Serializable, PropertyChangeListener {
- public final int POSITIVE_SCROLL = 1;
- public final int NEGATIVE_SCROLL = -1;
- public final int MIN_SCROLL = -2;
- public final int MAX_SCROLL = 2;
- protected ScrollListener scrollListener;
- protected Timer scrollTimer;
- protected JSlider slider;
- protected Rectangle labelRect = new Rectangle(0, 0, 0, 0);
- protected int trackBuffer = 0;
- private static final int TICK_SPACE = 8;
- private static final Dimension PREFERRED_HORIZONTAL_SIZE = new Dimension(164, 21);
- private static final Dimension PREFERRED_VERTICAL_SIZE = new Dimension(21, 164);
- private static final Dimension MINIMUM_HORIZONTAL_SIZE = new Dimension(36, 21);
- private static final Dimension MINIMUM_VERTICAL_SIZE = new Dimension(21, 36);
- private transient boolean isDragging;
- private TrackListener trackListener;
- private ModelListener modelListener;
- private SizingListener sizeListener;
- private FListener focusListener;
- private Rectangle thumbRect = new Rectangle(0, 0, 0, 0);
- private Color shadowColor;
- private Color highlightColor;
- private Color focusColor;
-
- public BasicSliderUI(JSlider b) {
- }
-
- public void calculateThumbBounds() {
- if (this.slider.getOrientation() == 1) {
- this.setThumbBounds(this.getScrollTrackRect().x, this.yPositionForValue(this.slider.getValue()) - this.getThumbRect().height / 2, this.getScrollTrackRect().width, 11);
- } else {
- this.setThumbBounds(this.xPositionForValue(this.slider.getValue()) - this.getThumbRect().width / 2, this.getScrollTrackRect().y, 11, this.getScrollTrackRect().height);
- }
-
- }
-
- public static ComponentUI createUI(JComponent b) {
- return new BasicSliderUI((JSlider)b);
- }
-
- public Color getFocusColor() {
- return this.focusColor;
- }
-
- protected Rectangle getFullContentArea() {
- Rectangle r = new Rectangle();
- Insets insets = this.slider.getInsets();
- Dimension size = this.slider.getSize();
- r.x = insets.left;
- r.y = insets.top;
- r.width = size.width - (insets.left + insets.right);
- r.height = size.height - (insets.top + insets.bottom);
- return r;
- }
-
- protected int getHeightOfHighValueLabel() {
- Component label = this.getHighestValueLabel();
- int height = 0;
- if (label != null) {
- height = label.getPreferredSize().height;
- }
-
- return height;
- }
-
- protected int getHeightOfLowValueLabel() {
- Component label = this.getLowestValueLabel();
- int height = 0;
- if (label != null) {
- height = label.getPreferredSize().height;
- }
-
- return height;
- }
-
- protected int getHeightOfTallestLabel() {
- Dictionary dictionary = this.slider.getLabelTable();
- int tallest = 0;
- Component label;
- if (dictionary != null) {
- for(Enumeration keys = dictionary.keys(); keys.hasMoreElements(); tallest = Math.max(label.getPreferredSize().height, tallest)) {
- label = (Component)dictionary.get(keys.nextElement());
- }
- }
-
- return tallest;
- }
-
- protected Component getHighestValueLabel() {
- Dictionary dictionary = this.slider.getLabelTable();
- Component label = null;
- if (dictionary != null) {
- Enumeration keys = dictionary.keys();
- if (keys.hasMoreElements()) {
- int highestValue;
- int value;
- for(highestValue = (Integer)keys.nextElement(); keys.hasMoreElements(); highestValue = Math.max(value, highestValue)) {
- value = (Integer)keys.nextElement();
- }
-
- label = (Component)dictionary.get(new Integer(highestValue));
- }
- }
-
- return label;
- }
-
- public Color getHighlightColor() {
- return this.highlightColor;
- }
-
- public Rectangle getLabelRect() {
- return this.labelRect;
- }
-
- protected Component getLowestValueLabel() {
- Dictionary dictionary = this.slider.getLabelTable();
- Component label = null;
- if (dictionary != null) {
- Enumeration keys = dictionary.keys();
- if (keys.hasMoreElements()) {
- int lowestValue;
- int value;
- for(lowestValue = (Integer)keys.nextElement(); keys.hasMoreElements(); lowestValue = Math.min(value, lowestValue)) {
- value = (Integer)keys.nextElement();
- }
-
- label = (Component)dictionary.get(new Integer(lowestValue));
- }
- }
-
- return label;
- }
-
- public Dimension getMaximumSize(JComponent c) {
- Dimension d = this.getPreferredSize(c);
- if (this.slider.getOrientation() == 1) {
- d.height = 32767;
- } else {
- d.width = 32767;
- }
-
- return d;
- }
-
- public Dimension getMinimumHorizontalSize() {
- return MINIMUM_HORIZONTAL_SIZE;
- }
-
- public Dimension getMinimumSize(JComponent c) {
- Dimension d;
- if (this.slider.getOrientation() == 1) {
- d = new Dimension(this.getMinimumVerticalSize());
- if (this.slider.getPaintTicks()) {
- d.width += this.getTickSpace() + 1;
- }
-
- if (this.slider.getPaintLabels()) {
- d.width += this.getLabelRect().width + 1;
- }
- } else {
- d = new Dimension(this.getMinimumHorizontalSize());
- if (this.slider.getPaintTicks()) {
- d.height += this.getTickSpace() + 1;
- }
-
- if (this.slider.getPaintLabels()) {
- d.height += this.getLabelRect().height + 1;
- }
- }
-
- d.width += this.slider.getInsets().left + this.slider.getInsets().right;
- d.height += this.slider.getInsets().top + this.slider.getInsets().bottom;
- return d;
- }
-
- public Dimension getMinimumVerticalSize() {
- return MINIMUM_VERTICAL_SIZE;
- }
-
- public Dimension getPreferredHorizontalSize() {
- return PREFERRED_HORIZONTAL_SIZE;
- }
-
- public Dimension getPreferredSize(JComponent c) {
- Dimension d;
- if (this.slider.getOrientation() == 1) {
- d = new Dimension(this.getPreferredVerticalSize());
- if (this.slider.getPaintTicks()) {
- d.width += this.getScrollTickRect().width + 1;
- }
-
- if (this.slider.getPaintLabels()) {
- d.width += this.getLabelRect().width + 1;
- }
- } else {
- d = new Dimension(this.getPreferredHorizontalSize());
- if (this.slider.getPaintTicks()) {
- d.height += this.getScrollTickRect().height + 1;
- }
-
- if (this.slider.getPaintLabels()) {
- d.height += this.getLabelRect().height + 1;
- }
- }
-
- d.width += this.slider.getInsets().left + this.slider.getInsets().right;
- d.height += this.slider.getInsets().top + this.slider.getInsets().bottom;
- return d;
- }
-
- public Dimension getPreferredVerticalSize() {
- return PREFERRED_VERTICAL_SIZE;
- }
-
- public Rectangle getScrollTickRect() {
- Rectangle r = this.getFullContentArea();
- if (this.slider.getPaintTicks()) {
- Rectangle labelRect = this.getLabelRect();
- if (this.slider.getOrientation() == 1) {
- if (this.slider.getPaintLabels()) {
- r.setLocation(labelRect.x - 1 - this.getTickSize(), r.y);
- } else {
- r.setLocation(r.x + (r.width - 1) - this.getTickSize(), r.y);
- }
-
- r.setSize(this.getTickSize(), r.height);
- } else {
- if (this.slider.getPaintLabels()) {
- r.setLocation(r.x, labelRect.y - 1 - this.getTickSize());
- } else {
- r.setLocation(r.x, r.y + (r.height - 1) - this.getTickSize());
- }
-
- r.setSize(r.width, this.getTickSize());
- }
- } else {
- r.setLocation(this.labelRect.x, this.labelRect.y);
- if (this.slider.getOrientation() == 1) {
- r.setSize(0, r.height);
- } else {
- r.setSize(r.width, 0);
- }
- }
-
- return r;
- }
-
- public Rectangle getScrollTrackRect() {
- Rectangle r = this.getFullContentArea();
- if (this.slider.getPaintTicks() || this.slider.getPaintLabels()) {
- if (this.slider.getOrientation() == 0) {
- r.setSize(r.width, this.getScrollTickRect().y - 1 - r.y);
- } else {
- r.setSize(this.getScrollTickRect().x - 1 - r.x, r.height);
- }
- }
-
- return r;
- }
-
- public Color getShadowColor() {
- return this.shadowColor;
- }
-
- public Rectangle getThumbRect() {
- return this.thumbRect;
- }
-
- public int getTickSize() {
- return this.getTickSpace();
- }
-
- public int getTickSpace() {
- return 8;
- }
-
- protected int getWidthOfHighValueLabel() {
- Component label = this.getHighestValueLabel();
- int width = 0;
- if (label != null) {
- width = label.getPreferredSize().width;
- }
-
- return width;
- }
-
- protected int getWidthOfLowValueLabel() {
- Component label = this.getLowestValueLabel();
- int width = 0;
- if (label != null) {
- width = label.getPreferredSize().width;
- }
-
- return width;
- }
-
- protected int getWidthOfWidestLabel() {
- Dictionary dictionary = this.slider.getLabelTable();
- int widest = 0;
- Component label;
- if (dictionary != null) {
- for(Enumeration keys = dictionary.keys(); keys.hasMoreElements(); widest = Math.max(label.getPreferredSize().width, widest)) {
- label = (Component)dictionary.get(keys.nextElement());
- }
- }
-
- return widest;
- }
-
- public void installUI(JComponent c) {
- this.slider = (JSlider)c;
- LookAndFeel.installBorder(this.slider, "Slider.border");
- LookAndFeel.installColors(this.slider, "Slider.background", "Slider.foreground");
- this.highlightColor = UIManager.getColor("Slider.highlight");
- this.shadowColor = UIManager.getColor("Slider.shadow");
- this.focusColor = UIManager.getColor("Slider.focus");
- this.isDragging = false;
- this.trackListener = new TrackListener(this);
- this.modelListener = new ModelListener(this);
- this.sizeListener = new SizingListener(this);
- this.focusListener = new FListener(this);
- this.scrollListener = new ScrollListener(this);
- this.scrollTimer = new Timer(100, this.scrollListener);
- this.scrollTimer.setInitialDelay(300);
- this.slider.addMouseListener(this.trackListener);
- this.slider.addMouseMotionListener(this.trackListener);
- this.slider.addFocusListener(this.focusListener);
- this.slider.addComponentListener(this.sizeListener);
- this.slider.addPropertyChangeListener(this);
- this.slider.getModel().addChangeListener(this.modelListener);
- this.slider.setEnabled(this.slider.isEnabled());
- this.slider.setOpaque(true);
- this.calculateThumbBounds();
- this.recalcLabelRect();
- this.recalcTrackBuffer();
- this.calculateThumbBounds();
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, 1, false), KeyStroke.getKeyStroke(39, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, -1, false), KeyStroke.getKeyStroke(40, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, -1, true), KeyStroke.getKeyStroke(34, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, -1, false), KeyStroke.getKeyStroke(37, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, 1, false), KeyStroke.getKeyStroke(38, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, 1, true), KeyStroke.getKeyStroke(33, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, -2, true), KeyStroke.getKeyStroke(36, 0), 0);
- this.slider.registerKeyboardAction(new ActionScroller(this, this.slider, 2, true), KeyStroke.getKeyStroke(35, 0), 0);
- }
-
- public void paint(Graphics g, JComponent c) {
- this.paintTrack(g);
- if (this.slider.getPaintTicks()) {
- this.paintTicks(g);
- }
-
- if (this.slider.getPaintLabels()) {
- this.paintLabels(g);
- }
-
- this.paintFocus(g);
- this.paintThumb(g);
- }
-
- public void paintFocus(Graphics g) {
- if (this.slider.hasFocus()) {
- Rectangle r = this.slider.getBounds();
- r.x = 0;
- r.y = 0;
- if (this.slider.getBorder() != null) {
- r = this.getFullContentArea();
- }
-
- g.setColor(this.getFocusColor());
- BasicGraphicsUtils.drawDashedRect(g, r.x + 1, r.y + 1, r.width - 2, r.height - 2);
- }
-
- }
-
- protected void paintHorizontalLabel(Graphics g, int value, Component label) {
- int labelCenter = this.xPositionForValue(value);
- int labelLeft = labelCenter - label.getPreferredSize().width / 2;
- g.translate(labelLeft, 0);
- label.paint(g);
- g.translate(-labelLeft, 0);
- }
-
- public void paintLabels(Graphics g) {
- Rectangle labelBounds = this.getLabelRect();
- g.translate(labelBounds.x, labelBounds.y);
- Dictionary dictionary = this.slider.getLabelTable();
- if (dictionary != null) {
- Enumeration keys = dictionary.keys();
-
- while(keys.hasMoreElements()) {
- Integer key = (Integer)keys.nextElement();
- Component label = (Component)dictionary.get(key);
- if (this.slider.getOrientation() == 0) {
- this.paintHorizontalLabel(g, key, label);
- } else {
- this.paintVerticalLabel(g, key, label);
- }
- }
- }
-
- g.translate(-labelBounds.x, -labelBounds.y);
- }
-
- protected void paintMajorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) {
- g.drawLine(x, 0, x, tickBounds.height - 2);
- }
-
- protected void paintMajorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) {
- g.drawLine(0, y, tickBounds.width - 2, y);
- }
-
- protected void paintMinorTickForHorizSlider(Graphics g, Rectangle tickBounds, int x) {
- g.drawLine(x, 0, x, tickBounds.height / 2 - 1);
- }
-
- protected void paintMinorTickForVertSlider(Graphics g, Rectangle tickBounds, int y) {
- g.drawLine(0, y, tickBounds.width / 2 - 1, y);
- }
-
- public void paintThumb(Graphics g) {
- Rectangle knobBounds = this.getThumbRect();
- int w = knobBounds.width;
- int h = knobBounds.height;
- g.translate(knobBounds.x, knobBounds.y);
- if (this.slider.isEnabled()) {
- g.setColor(this.slider.getBackground());
- } else {
- g.setColor(this.slider.getBackground().darker());
- }
-
- if (!this.slider.getPaintTicks()) {
- g.fillRect(0, 0, w, h);
- g.setColor(Color.black);
- g.drawLine(0, h - 1, w - 1, h - 1);
- g.drawLine(w - 1, 0, w - 1, h - 1);
- g.setColor(BasicGraphicsUtils.controlHighlight);
- g.drawLine(0, 0, 0, h - 2);
- g.drawLine(1, 0, w - 2, 0);
- g.setColor(BasicGraphicsUtils.controlShadow);
- g.drawLine(1, h - 2, w - 2, h - 2);
- g.drawLine(w - 2, 1, w - 2, h - 3);
- } else if (this.slider.getOrientation() == 0) {
- int cw = w / 2;
- g.fillRect(1, 1, w - 3, h - 1 - cw);
- Polygon p = new Polygon();
- p.addPoint(1, h - cw);
- p.addPoint(cw - 1, h - 1);
- p.addPoint(w - 2, h - 1 - cw);
- g.fillPolygon(p);
- g.setColor(BasicGraphicsUtils.controlHighlight);
- g.drawLine(0, 0, w - 2, 0);
- g.drawLine(0, 1, 0, h - 1 - cw);
- g.drawLine(0, h - cw, cw - 1, h - 1);
- g.setColor(Color.black);
- g.drawLine(w - 1, 0, w - 1, h - 2 - cw);
- g.drawLine(w - 1, h - 1 - cw, w - 1 - cw, h - 1);
- g.setColor(BasicGraphicsUtils.controlShadow);
- g.drawLine(w - 2, 1, w - 2, h - 2 - cw);
- g.drawLine(w - 2, h - 1 - cw, w - 1 - cw, h - 2);
- } else {
- int cw = h / 2;
- g.fillRect(1, 1, w - 1 - cw, h - 3);
- Polygon p = new Polygon();
- p.addPoint(w - cw - 1, 0);
- p.addPoint(w - 1, cw);
- p.addPoint(w - 1 - cw, h - 2);
- g.fillPolygon(p);
- g.setColor(BasicGraphicsUtils.controlHighlight);
- g.drawLine(0, 0, 0, h - 2);
- g.drawLine(1, 0, w - 1 - cw, 0);
- g.drawLine(w - cw - 1, 0, w - 1, cw);
- g.setColor(Color.black);
- g.drawLine(0, h - 1, w - 2 - cw, h - 1);
- g.drawLine(w - 1 - cw, h - 1, w - 1, h - 1 - cw);
- g.setColor(BasicGraphicsUtils.controlShadow);
- g.drawLine(1, h - 2, w - 2 - cw, h - 2);
- g.drawLine(w - 1 - cw, h - 2, w - 2, h - cw - 1);
- }
-
- g.translate(-knobBounds.x, -knobBounds.y);
- }
-
- public void paintTicks(Graphics g) {
- Rectangle tickBounds = this.getScrollTickRect();
- int var10000 = tickBounds.width;
- var10000 = tickBounds.height;
- g.translate(tickBounds.x, tickBounds.y);
- g.setColor(this.slider.getBackground());
- g.fillRect(0, 0, tickBounds.width, tickBounds.height);
- g.setColor(Color.black);
- this.slider.getMajorTickSpacing();
- this.slider.getMinorTickSpacing();
- if (this.slider.getOrientation() == 0) {
- int value = this.slider.getMinimum();
- int xPos = 0;
- if (this.slider.getMinorTickSpacing() > 0) {
- while(value <= this.slider.getMaximum()) {
- xPos = this.xPositionForValue(value);
- this.paintMinorTickForHorizSlider(g, tickBounds, xPos);
- value += this.slider.getMinorTickSpacing();
- }
- }
-
- if (this.slider.getMajorTickSpacing() > 0) {
- for(int var5 = this.slider.getMinimum(); var5 <= this.slider.getMaximum(); var5 += this.slider.getMajorTickSpacing()) {
- xPos = this.xPositionForValue(var5);
- this.paintMajorTickForHorizSlider(g, tickBounds, xPos);
- }
- }
- } else {
- int value = this.slider.getMinimum();
- int yPos = 0;
- if (this.slider.getMinorTickSpacing() > 0) {
- while(value <= this.slider.getMaximum()) {
- yPos = this.yPositionForValue(value);
- this.paintMinorTickForVertSlider(g, tickBounds, yPos);
- value += this.slider.getMinorTickSpacing();
- }
- }
-
- if (this.slider.getMajorTickSpacing() > 0) {
- for(int var7 = this.slider.getMinimum(); var7 <= this.slider.getMaximum(); var7 += this.slider.getMajorTickSpacing()) {
- yPos = this.yPositionForValue(var7);
- this.paintMajorTickForVertSlider(g, tickBounds, yPos);
- }
- }
- }
-
- g.translate(-tickBounds.x, -tickBounds.y);
- }
-
- public void paintTrack(Graphics g) {
- Rectangle trackBounds = this.getScrollTrackRect();
- int cx;
- int cy;
- if (this.slider.getOrientation() == 0) {
- int pad = this.trackBuffer;
- cx = pad;
- cy = trackBounds.height / 2 - 2;
- int cw = trackBounds.width - this.trackBuffer * 2;
- g.translate(trackBounds.x + pad, trackBounds.y + cy);
- g.setColor(this.getShadowColor());
- g.drawLine(0, 0, cw - 1, 0);
- g.drawLine(0, 1, 0, 2);
- g.setColor(this.getHighlightColor());
- g.drawLine(0, 3, cw, 3);
- g.drawLine(cw, 0, cw, 3);
- g.setColor(Color.black);
- g.drawLine(1, 1, cw - 2, 1);
- } else {
- int var8 = this.trackBuffer;
- cx = trackBounds.width / 2 - 2;
- cy = var8;
- int ch = trackBounds.height - this.trackBuffer * 2;
- g.translate(trackBounds.x + cx, trackBounds.y + var8);
- g.setColor(this.getShadowColor());
- g.drawLine(0, 0, 0, ch - 1);
- g.drawLine(1, 0, 2, 0);
- g.setColor(this.getHighlightColor());
- g.drawLine(3, 0, 3, ch);
- g.drawLine(0, ch, 3, ch);
- g.setColor(Color.black);
- g.drawLine(1, 1, 1, ch - 2);
- }
-
- g.translate(-(trackBounds.x + cx), -(trackBounds.y + cy));
- }
-
- protected void paintVerticalLabel(Graphics g, int value, Component label) {
- int labelCenter = this.yPositionForValue(value);
- int labelTop = labelCenter - label.getPreferredSize().height / 2;
- g.translate(0, labelTop);
- label.paint(g);
- g.translate(0, -labelTop);
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("labelTable")) {
- this.recalcLabelRect();
- this.recalcTrackBuffer();
- }
-
- }
-
- protected void recalcLabelRect() {
- Rectangle interior = this.getFullContentArea();
- if (this.slider.getPaintLabels()) {
- if (this.slider.getOrientation() == 0) {
- int maxLabelHeight = this.getHeightOfTallestLabel();
- interior.y = interior.y + (interior.height - 1) - maxLabelHeight;
- interior.height = maxLabelHeight;
- } else {
- int maxLabelWidth = this.getWidthOfWidestLabel();
- interior.x = interior.x + (interior.width - 1) - maxLabelWidth;
- interior.width = maxLabelWidth;
- }
- } else if (this.slider.getOrientation() == 1) {
- interior.setLocation(interior.x + (interior.width - 1), interior.y);
- interior.setSize(0, interior.height);
- } else {
- interior.setLocation(interior.x, interior.y + (interior.height - 1));
- interior.setSize(interior.width, 0);
- }
-
- this.labelRect = interior;
- }
-
- protected void recalcTrackBuffer() {
- if (this.slider.getPaintLabels() && this.slider.getLabelTable() != null) {
- Component highLabel = this.getHighestValueLabel();
- Component lowLabel = this.getLowestValueLabel();
- if (this.slider.getOrientation() == 0) {
- this.trackBuffer = Math.max(highLabel.getBounds().width, lowLabel.getBounds().width) / 2;
- this.trackBuffer = Math.max(this.trackBuffer, this.getThumbRect().width / 2);
- } else {
- this.trackBuffer = Math.max(highLabel.getBounds().height, lowLabel.getBounds().height) / 2;
- this.trackBuffer = Math.max(this.trackBuffer, this.getThumbRect().height / 2);
- }
- } else if (this.slider.getOrientation() == 0) {
- this.trackBuffer = this.getThumbRect().width / 2;
- } else {
- this.trackBuffer = this.getThumbRect().height / 2;
- }
-
- }
-
- public void scrollByBlock(int direction) {
- synchronized(this.slider){}
-
- try {
- int oldValue = this.slider.getValue();
- int blockIncrement = this.slider.getMaximum() / 10;
- int delta = blockIncrement * (direction > 0 ? 1 : -1);
- this.slider.setValue(oldValue + delta);
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public void scrollByUnit(int direction) {
- synchronized(this.slider){}
-
- try {
- int oldValue = this.slider.getValue();
- int delta = 1 * (direction > 0 ? 1 : -1);
- this.slider.setValue(oldValue + delta);
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- protected void scrollDueToClickInTrack(int dir) {
- this.scrollByBlock(dir);
- }
-
- public void setThumbBounds(int x, int y, int width, int height) {
- Rectangle r = new Rectangle(this.thumbRect.x, this.thumbRect.y, this.thumbRect.width, this.thumbRect.height);
- this.thumbRect.setBounds(x, y, width, height);
- Rectangle r2 = r.union(this.thumbRect);
- this.slider.repaint(r2.x, r2.y, r2.width, r2.height);
- }
-
- public void setThumbLocation(int x, int y) {
- Rectangle r = new Rectangle(this.thumbRect.x, this.thumbRect.y, this.thumbRect.width, this.thumbRect.height);
- this.thumbRect.setLocation(x, y);
- Rectangle r2 = r.union(this.thumbRect);
- this.slider.repaint(r2.x, r2.y, r2.width, r2.height);
- }
-
- public void uninstallUI(JComponent c) {
- if (c != this.slider) {
- throw new IllegalComponentStateException(this + " was asked to deinstall() " + c + " when it only knows about " + this.slider + ".");
- } else {
- LookAndFeel.uninstallBorder(this.slider);
- this.scrollTimer.stop();
- this.scrollTimer = null;
- this.slider.getModel().removeChangeListener(this.modelListener);
- this.slider.removeMouseListener(this.trackListener);
- this.slider.removeMouseMotionListener(this.trackListener);
- this.slider.removeFocusListener(this.focusListener);
- this.slider.removeComponentListener(this.sizeListener);
- this.slider.removePropertyChangeListener(this);
- this.slider.resetKeyboardActions();
- this.thumbRect = null;
- this.slider = null;
- }
- }
-
- protected int xPositionForValue(int randomValue) {
- int min = this.slider.getMinimum();
- this.slider.getMaximum();
- Rectangle trackRect = this.getScrollTrackRect();
- int trackLength = trackRect.width - this.trackBuffer * 2;
- int valueRange = this.slider.getMaximum() - this.slider.getMinimum();
- double pixelsPerValue = (double)trackLength / (double)valueRange;
- int trackLeft = trackRect.x + this.trackBuffer;
- int trackRight = trackRect.x + (trackRect.width - 1) - this.trackBuffer;
- int xPosition;
- if (!this.slider.getInverted()) {
- xPosition = (int)((long)trackLeft + Math.round(pixelsPerValue * (double)(randomValue - min)));
- } else {
- xPosition = (int)((long)trackRight - Math.round(pixelsPerValue * (double)(randomValue - min)));
- }
-
- xPosition = Math.max(trackLeft, xPosition);
- xPosition = Math.min(trackRight, xPosition);
- return xPosition;
- }
-
- protected int yPositionForValue(int randomValue) {
- int min = this.slider.getMinimum();
- int max = this.slider.getMaximum();
- Rectangle trackRect = this.getScrollTrackRect();
- int trackLength = trackRect.height - this.trackBuffer * 2;
- int valueRange = this.slider.getMaximum() - this.slider.getMinimum();
- double pixelsPerValue = (double)trackLength / (double)valueRange;
- int trackTop = trackRect.y + this.trackBuffer;
- int trackBottom = trackRect.y + (trackRect.height - 1) - this.trackBuffer;
- int yPosition;
- if (!this.slider.getInverted()) {
- yPosition = (int)((long)trackTop + Math.round(pixelsPerValue * (double)(max - randomValue)));
- } else {
- yPosition = (int)((long)trackTop + Math.round(pixelsPerValue * (double)(randomValue - min)));
- }
-
- yPosition = Math.max(trackTop, yPosition);
- yPosition = Math.min(trackBottom, yPosition);
- return yPosition;
- }
-
- static TrackListener access$trackListener(BasicSliderUI var0) {
- return var0.trackListener;
- }
-
- static boolean access$isDragging(BasicSliderUI var0) {
- return var0.isDragging;
- }
-
- static void access$isDragging(BasicSliderUI var0, boolean var1) {
- var0.isDragging = var1;
- }
- }
-